package net.zjitc.object.random;

import java.util.Scanner;

/**
 * @Author admin
 * @Date 2019/3/15 8:15
 */
public class Test {

    public static void main(String[] args) {
        /* 让对象做：产生随机数，判断猜大猜小，猜测次数
         *  自己做的事情：接收用户输入数字，根据猜测结果决定是否要重复让用户输入*/
        Guess guess = new Guess();
        guess.getRandom();
        System.out.println("随机数已经产生");
        String result = "";
        do {
            System.out.println("请输入要猜测的值：");
            Scanner scanner = new Scanner(System.in);
            int g = scanner.nextInt();
            /* 调用guess对象的judge方法，传递用户输入的猜测值，
              该方法返回结果：bigger、smaller、binGo
             *   */
            result = guess.judge(g);
            System.out.println(result);
        } while (!result.equals("binGo"));
        System.out.println("共猜测了"+guess.getCount()+"次");
        System.out.println("Game Over!");
    }
}
